import { ReactiveProperty } from './ReactiveProperty';
import { Asap } from './CreatorSchedule';
import { _decorator } from 'cc';
import { EDITOR } from 'cc/env';
const { ccclass, property, float } = _decorator;

/*

    注意：
        在多级Prefab嵌套中，出现过异常，导致ReactiveString的实例为空。
        断开Prefab的关联后正常，重新拉为Prefab即可 2023/05/18

*/

@ccclass('ReactiveString')
export class ReactiveString extends ReactiveProperty<string> {

    constructor() {
        super();
        this.init(this.Value);
    }

    static DefaultValue(value?: string): ReactiveString {
        let rp = new ReactiveString();
        if (value != null) rp.Value = value;
        return rp;
    }

    @property
    private _Value: string = '';
    @property
    public get Value(): string { return this._Value; }
    public set Value(v: string) { this._Value = v; if (this._subject) this.value = v; }

    loadValue() {
        this.value = this.Value;
    }
}

